﻿package ui
{
	import adpter.GameUIAdapter;
	import adpter.layer.MapLayerAdapter;
	import adpter.layer.RoleLayerAdapter;
	
	import datapool.global.GlobalInfo;
	
	import flash.display.Stage;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	
	import ui.common.SpriteObject;
	import ui.layer.MapLayerUI;
	import ui.layer.RoleLayerUI;
	
	public class GameUI extends SpriteObject
	{
		private var _gameUIAdapter:GameUIAdapter;
		
		private var _mapLayer:MapLayerUI;
		private var _roleLayer:RoleLayerUI;
		
		public function GameUI()
		{
			super();
			init();
		}
		
		private function init():void
		{			
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align     = StageAlign.TOP_LEFT;
			GlobalInfo.stageHight = stage.stageHeight;
			GlobalInfo.stageWidth = stage.stageWidth;
			
			
			_mapLayer = new MapLayerUI();
			addChild(_mapLayer);
			
			_roleLayer = new RoleLayerUI();
			addChild(_roleLayer);
			
			_gameUIAdapter = new GameUIAdapter();
			_gameUIAdapter.update();
			attachAdapter(_gameUIAdapter);
		}
		
		protected function get gameUIAdapter():GameUIAdapter
		{
			return adapter as GameUIAdapter;
		}
		
		public function updateMapLayerAdapter(adapter:MapLayerAdapter):void
		{
			_mapLayer.attachAdapter(adapter);
		}
		
		public function updateRoleLayerAdapter(adapter:RoleLayerAdapter):void
		{
			_roleLayer.attachAdapter(adapter);
		}
	}
}